package com.chb.facade;

/**
 * @author chihb
 * @create-time 2024/10/23 16:54
 * @description
 */
public class SmartAppliancesFacade {
    private AirCondition airCondition;
    private Light light;
    private TV tv;
    public SmartAppliancesFacade(){
        airCondition = new AirCondition();
        light = new Light();
        tv = new TV();
    }

    public void say(String meg){
        if(meg.contains("打开")){
            on();
        }else if(meg.contains("关闭")){
            off();
        }else {
            new RuntimeException("没有这个命令");
        }
    }
    private void off(){
        airCondition.off();
        light.off();
        tv.off();
    }

    private void on(){
        airCondition.on();
        light.on();
        tv.on();
    }
}
